//
//  MainTabViewController.swift
//  SLQuickReader
//
//  Created by ALin on 2017/8/2.
//  Copyright © 2017年 ALin. All rights reserved.
//

import UIKit
import RxCocoa
import RxSwift

class MainTabViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupChildrenViewControllers()
    }
    
    func setupChildrenViewControllers() {
        configChild(BookshelfViewController(), title: local("book_shelf"), imageName: "hw_tabbar_shelf_none_21x21_")
        configChild(BookstoreViewController(), title: local("book_store"), imageName: "hw_tabbar_books_none_21x21_")
//        configChild(RankingViewController(), title: local("ranking"), imageName: "hw_tabbar_hot_none_21x21_")
        configChild(SettingViewController.loadFromSB(), title: local("setting"), imageName: "hw_tabbar_find_none_21x21_")
    }
    
    
    func configChild(_ child: UIViewController, title: String, imageName: String) {
        let nav = UINavigationController(rootViewController: child)
        child.navigationItem.title = title
        child.tabBarItem.title = title
        child.tabBarItem.image = UIImage(named: imageName)
        child.tabBarItem.selectedImage = UIImage(named: imageName.replacingOccurrences(of: "none", with: "selected"))
        addChildViewController(nav)
    }

}
